Namespace Model.TaskQuery
  Public MustInherit Class AbstractTaskQuery

    Protected mSuccess As Boolean = False
    Private mFoundTask As Task = Nothing

    MustOverride Sub Inspect(ByVal task As Task)

    ''' <summary>
    ''' internal sub to shortcircuit the process
    ''' </summary>
    ''' <remarks></remarks>
    Protected Overridable Sub PublishResult(ByVal result As Task)
      mSuccess = (result IsNot Nothing)
      mFoundTask = result
    End Sub

    ''' <summary>
    ''' indicates whether the query was succesful
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public ReadOnly Property Success() As Boolean
      Get
        Return mSuccess
      End Get
    End Property

    ''' <summary>
    ''' if the query results in 1 task, this is
    ''' the task that had to be found or nothing 
    ''' if no task was found
    ''' </summary>
    Public ReadOnly Property Result() As Task
      Get
        Return mFoundTask
      End Get
    End Property
  End Class
End Namespace